﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SortedLisTest
{
    class Program
    {
        static void Main(string[] args)
        {
            SortedList sortList = new SortedList(); 
            sortList.Add(1, "椰果");
            sortList.Add(2, "芋圆");
            sortList.Add(3, "小汤圆"); 
            Console.WriteLine("请输入你冰粉里所需配料编号："); 
            int id = int.Parse(Console.ReadLine()); 
            bool flag = sortList.ContainsKey(id);
            if (flag) { 
                string name = sortList[id].ToString();
                Console.WriteLine("您所加的配料为：{0}", name); 
            } 
            else 
            { 
                Console.WriteLine("您所需的配料不存在！");
            }
            Console.WriteLine("所有配料信息如下：");
            foreach (DictionaryEntry d in sortList) 
            { int key = (int)d.Key; 
                string value = d.Value.ToString();
                Console.WriteLine("配料编号：{0}，配料名称：{1}", key, value);
            }
        }
    }
}
